package cn.iocoder.yudao.module.bpm.dal.mysql.tohandle;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.enums.DeletedConstants;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.bpm.controller.admin.tohandle.sourceconfig.vo.BpmHandleSourceConfigExportReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.tohandle.sourceconfig.vo.BpmHandleSourceConfigPageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.tohandle.BpmHandleSourceConfigDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface BpmHandleSourceConfigMapper extends BaseMapperX<BpmHandleSourceConfigDO> {

    default PageResult<BpmHandleSourceConfigDO> selectPage(BpmHandleSourceConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BpmHandleSourceConfigDO>()
                .likeIfPresent(BpmHandleSourceConfigDO::getSourceSystem, reqVO.getSourceSystem())
                .eqIfPresent(BpmHandleSourceConfigDO::getSourceUrlRule, reqVO.getSourceUrlRule())
                .betweenIfPresent(BpmHandleSourceConfigDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(BpmHandleSourceConfigDO::getUpdateTime, reqVO.getUpdateTime())
                .likeIfPresent(BpmHandleSourceConfigDO::getCreator, reqVO.getCreator())
                .eqIfPresent(BpmHandleSourceConfigDO::getUpdater, reqVO.getUpdater())
                .eqIfPresent(BpmHandleSourceConfigDO::getDeleted, reqVO.getDeleted())
                .eqIfPresent(BpmHandleSourceConfigDO::getTestFlag, reqVO.getTestFlag())
                .orderByDesc(BpmHandleSourceConfigDO::getId));
    }

    default List<BpmHandleSourceConfigDO> selectList(BpmHandleSourceConfigExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BpmHandleSourceConfigDO>()
                .likeIfPresent(BpmHandleSourceConfigDO::getSourceSystem, reqVO.getSourceSystem())
                .eqIfPresent(BpmHandleSourceConfigDO::getSourceUrlRule, reqVO.getSourceUrlRule())
                .betweenIfPresent(BpmHandleSourceConfigDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(BpmHandleSourceConfigDO::getUpdateTime, reqVO.getUpdateTime())
                .likeIfPresent(BpmHandleSourceConfigDO::getCreator, reqVO.getCreator())
                .eqIfPresent(BpmHandleSourceConfigDO::getUpdater, reqVO.getUpdater())
                .eqIfPresent(BpmHandleSourceConfigDO::getDeleted, reqVO.getDeleted())
                .eqIfPresent(BpmHandleSourceConfigDO::getTestFlag, reqVO.getTestFlag())
                .orderByDesc(BpmHandleSourceConfigDO::getId));
    }

}
